home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_teo_gearlock.cog < prev    next >
Text File  |  1999-11-15  |  7KB  |  279 lines

  1. # Jones 3D Cog Script
  2. #
  3. # TEO_Gearlock.cog
  4. #
  5. # A hack for spinning blocks around.
  6. #
  7. # [SXC]
  8. #
  9. # (C) 1998 LucasArts Entertainment Co. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13.  
  14.     message        startup
  15.     message        activated
  16.     message        arrived
  17.     message     blocked
  18.     message        user0
  19.  
  20.     sector        doorsec0        nolink
  21.     sector        doorsec1        nolink
  22.     sector        doorsec2        nolink
  23.     sector        doorsec3        nolink
  24.  
  25.     sector        doorvis0        nolink
  26.     sector        doorvis1        nolink
  27.     sector        doorvis2        nolink
  28.     sector        doorvis3        nolink
  29.  
  30.     sound        statRotSnd
  31.     sound        statbutsnd
  32.     sound        butresetsnd
  33.     sound       yougotitwav=mus_gen_indy_b_motif1.wav   local
  34.  
  35.     thing        door0            linkid=6
  36.     thing        door1            linkid=6
  37.     thing        door2            linkid=6
  38.     thing        door3            linkid=6
  39.  
  40.     thing        gear0            nolink
  41.     thing        gear1            nolink
  42.     thing        gear2            nolink
  43.     thing        gear3            nolink
  44.  
  45.     thing        gearnode0        nolink
  46.     thing        gearnode1        nolink
  47.     thing        gearnode2        nolink
  48.     thing        gearnode3        nolink
  49.     thing        gearnode4        nolink
  50.     thing        gearnode5        nolink
  51.     thing        gearnode6        nolink
  52.     thing        gearnode7        nolink
  53.     thing        gearnode8        nolink
  54.     thing        gearnode9        nolink
  55.     thing        gearnodet        nolink
  56.     thing        gearnodee        nolink
  57.  
  58.     thing        doorcam0        nolink
  59.     thing        doorcam1        nolink
  60.     thing        doorcam2        nolink
  61.     thing        doorcam3        nolink
  62.  
  63.     thing        indyTarget        nolink
  64.  
  65.     thing        statue
  66.     thing        ghostcampos        nolink
  67.     thing        gear            nolink
  68.  
  69.     thing        statswitch
  70.  
  71.     thing        indy            nolink
  72.     thing        player            local
  73.  
  74.     flex        rottime=3.0        local
  75.     flex        moveSpeed=1.0    local
  76.  
  77.     vector        curnodepos        local
  78.     vector        curgearpos        local
  79.     vector      newgearvector   local
  80.  
  81.     int            rotsound        local
  82.     int            doorcount=0        local
  83.     int            nodecount=0        local
  84.     int            gearcount=0        local
  85.     int            flag=0            local
  86.     int            locked=0        local
  87.     int            currand            local
  88.     int            lastrand        local
  89.     int            bSpoken=0        local
  90.  
  91. end
  92.  
  93. #====================================================================================
  94.  
  95. code
  96.  
  97. startup:
  98.  
  99.     player = GetLocalPlayerThing();
  100.  
  101.     doorvis0 = GetThingSector(door0);
  102.     doorvis1 = GetThingSector(door1);
  103.     doorvis2 = GetThingSector(door2);
  104.     doorvis3 = GetThingSector(door3);
  105.  
  106.     for (doorcount=0; doorcount <=3; doorcount=doorcount+1)
  107.     {
  108.         sectoradjoins(doorvis0[doorcount], 0);
  109.     }
  110.  
  111. return;
  112.  
  113. #----------------------------------------------------------------------------------------
  114. activated:
  115.  
  116.     if (GetSenderRef() != statswitch) return;   
  117.     if (GetCurItem(player) != 0) return;
  118.     if (GetCurFrame(statue) != 3) return;
  119.     if (locked != 0) return;
  120.  
  121.     locked = 1;
  122.  
  123.     StopThing(player);
  124.     SetActorFlags(player, 0x200000);
  125.     DeselectWeaponWait(player);
  126.     StartCutscene(1);
  127.  
  128.     # Prep Actor
  129.     CopyPlayerHolsters(player, indy);
  130.     TeleportThing(indy, indyTarget);
  131.     CopyOrientAndPos(indy, player);
  132.     Sleep(0.01);
  133.     SetThingFlags(player, 0x80000);
  134.     ClearThingFlags(indy, 0x80000);
  135.  
  136.     # Camera...
  137.     SetExtCamOffset('-0.15 0.0 0.05');
  138.     //SetExtCamLookOffset('0.0 0.05 0.0');
  139.  
  140.     MoveToFrame(statswitch, 1, moveSpeed);
  141.     PlaySoundThing(statbutsnd, statswitch, 0.3, 3, 10, 0);
  142.     PlayMode(indy, 60, 1);
  143.  
  144.     Sleep(0.5);
  145.     SetCameraFocus(0, ghostcampos);
  146.     SetCurrentCamera(0);
  147.     Rotate(statue, -180, 1, rottime);
  148.     Rotate(gear, -180, 1, rottime);
  149.     rotsound = PlaySoundLocal(statRotSnd, 0.65, 0, 0x1, 0);
  150.  
  151.     # check for door opening
  152.     for (doorcount=0; doorcount<=3; doorcount=doorcount+1)
  153.     {
  154.         if (GetSectorThingCount(doorsec0[doorcount]) == 3)
  155.         {
  156.             SetCollideType(door0[doorcount], 0);
  157.             SetCameraFocus(0, doorcam0[doorcount]);
  158.             MoveToFrame(doorcam0[doorcount], 1, (moveSpeed+1));
  159.             SectorAdjoins(doorvis0[doorcount], 1);
  160.             if (GetCurFrame(door0[doorcount]) == 0)
  161.             {
  162.                 MoveToFrame(door0[doorcount], 1, 1);
  163.             }    
  164.         }
  165.     }
  166.  
  167.     # check nodes for gears
  168.     for (nodecount=0; nodecount<=3; nodecount=nodecount +1)
  169.     {
  170.         # innerloop
  171.         curnodepos = GetThingPos(gearnode0[nodecount]);    
  172.         for (gearcount=0; gearcount<=3; gearcount=gearcount+1)
  173.         {
  174.             curgearpos = GetThingPos(gear0[gearcount]);
  175.             if (VectorLen(VectorSub(curnodepos, curgearpos)) < 0.075)
  176.             {
  177.                 newgearvector = VectorSet(VectorX(curnodepos), VectorY(curnodepos), VectorZ(curgearpos));   
  178.                 MoveThingToPos(gear0[gearcount], newgearvector, 0);
  179.                 Rotate(gear0[gearcount], 180, 1, rottime);
  180.                 flag = 1;
  181.             }         
  182.         }
  183.         # middleloop
  184.         curnodepos = GetThingPos(gearnode0[nodecount + 4]);
  185.         for (gearcount=0; gearcount<=3; gearcount=gearcount+1)
  186.         {
  187.             curgearpos = GetThingPos(gear0[gearcount]);
  188.             if ((VectorLen(VectorSub(curnodepos, curgearpos)) < 0.075) && (flag == 1))
  189.             {
  190.                 newgearvector = VectorSet(VectorX(curnodepos), VectorY(curnodepos), VectorZ(curgearpos));   
  191.                 MoveThingToPos(gear0[gearcount], newgearvector, 0);
  192.                 Rotate(gear0[gearcount], -180, 1, rottime);
  193.                 flag = 2;
  194.             }
  195.         }
  196.         # outerloop
  197.         curnodepos = GetThingPos(gearnode0[nodecount + 8]);
  198.         
  199.         for (gearcount=0; gearcount<=3; gearcount=gearcount+1)
  200.         {
  201.             curgearpos = GetThingPos(gear0[gearcount]);
  202.             if ((VectorLen(VectorSub(curnodepos, curgearpos)) < 0.075) && (flag == 2))
  203.             {
  204.                 newgearvector = VectorSet(VectorX(curnodepos), VectorY(curnodepos), VectorZ(curgearpos));   
  205.                 MoveThingToPos(gear0[gearcount], newgearvector, 0);
  206.                 Rotate(gear0[gearcount], 180, 1, rottime);
  207.                 flag = 0;
  208.             }
  209.         }
  210.         flag = 0;
  211.     }
  212.  
  213. return;
  214.  
  215. # -----------------------------------------------------------------------------------
  216. arrived:
  217.  
  218.     if (GetSenderRef() == statue)
  219.     {
  220.         if (locked != 1) return;
  221.  
  222.         StopSound(rotsound, 0);
  223.  
  224.         SetCollideType(door0, 3);
  225.         SetCollideType(door1, 3);
  226.         SetCollideType(door2, 3);
  227.         SetCollideType(door3, 3);
  228.  
  229.         Sleep(0.5);
  230.         SetCurrentCamera(1);
  231.         MoveToFrame(statswitch, 0, moveSpeed);
  232.         PlaySoundThing(butresetsnd, statswitch, 0.3, 3, 10, 0);
  233.         WaitForStop(statswitch);
  234.  
  235.         SetThingFlags(indy, 0x80000);
  236.         ClearThingFlags(player, 0x80000);
  237.  
  238.         RestoreExtCam();
  239.  
  240.         if (bSpoken)
  241.         {
  242.             EndCutscene();
  243.             ClearActorFlags(player, 0x200000);
  244.         }
  245.  
  246.         locked = 0;
  247.     }
  248.     
  249.     if (GetSenderID() == 6)
  250.     {
  251.         PlaySoundLocal(yougotitwav, 1, 0, 0, 0);
  252.     }
  253.  
  254. return;
  255.  
  256. #----------------------------------------------------------------------------------------
  257. blocked:
  258.  
  259.     if ((GetSenderRef() == gear0) ||
  260.         (GetSenderRef() == gear1) ||
  261.         (GetSenderRef() == gear2) ||
  262.         (GetSenderRef() == gear3))
  263.         
  264.     {
  265.         print("I'm being blocked");
  266.         
  267.     }
  268.     
  269. return;
  270.  
  271. #----------------------------------------------------------------------------------------
  272. user0: # Indicates that Azerim line has been spoken
  273.  
  274.     bSpoken = 1;
  275.     
  276. return;
  277.  
  278. end
  279.